import request from 'umi-request';
import type { TableListParams } from './data.d';

export async function queryBookList(params?: TableListParams) {
  return request('/sapi/book/query/condition', {
    method: 'GET',
    params,
  });
}

export async function removeBookList(params: { key: number[] }) {
  return request('/sapi/book/batch/delete', {
    method: 'POST',
    data: params.key,
  });
}

export async function addBook(params: TableListParams) {
  return request('/sapi/book/add/book', {
    method: 'POST',
    data: {
      ...params
    },
  });
}

export async function updateBook(params: TableListParams) {
  return request('/sapi/book/update/book', {
    method: 'POST',
    data: {
      ...params
    },
  });
}

export async function deleteBook(id: number) {
  return request('/sapi/book/delete', {
    method: 'GET',
    params: {
      'id': id
    },
  });
}
